home *** CD-ROM | disk | FTP | other *** search
- { lines.pas -- Draw lines at random in a window }
-
- program Lines;
-
- uses WinTypes, WinProcs, WObjects;
-
- const
-
- timer_ID = 1;
-
- type
-
- LineApplication = object(TApplication)
- procedure InitMainWindow; virtual;
- end;
-
- PLineWindow = ^LineWindow;
- LineWindow = object(TWindow)
- procedure SetupWindow;
- virtual;
- procedure WMDestroy(var Msg: TMessage);
- virtual wm_First + wm_Destroy;
- procedure WMTimer(var Msg: TMessage);
- virtual wm_First + wm_Timer;
- end;
-
- { LineApplication }
-
- {- Initialize the application's window }
- procedure LineApplication.InitMainWindow;
- begin
- MainWindow := New(PLineWindow, Init(nil, 'Random Lines'))
- end;
-
- { LineWindow }
-
- {- Initialize the window's actions }
- procedure LineWindow.SetupWindow;
- begin
- TWindow.SetupWindow;
- SetTimer(HWindow, timer_ID, 100, nil)
- end;
-
- {- Intercept wm_Destroy message }
- procedure LineWindow.WMDestroy(var Msg: TMessage);
- begin
- KillTimer(HWindow, timer_ID);
- TWindow.WMDestroy(Msg)
- end;
-
- {- Display random lines }
- procedure LineWindow.WMTimer(var Msg: TMessage);
- var
- Dc: HDC;
- R: TRect;
- begin
- Dc := GetDC(HWindow);
- GetClientRect(HWindow, R);
- MoveTo(Dc, Random(R.Right), Random(R.Bottom));
- LineTo(Dc, Random(R.Right), Random(R.Bottom));
- ReleaseDC(HWindow, Dc)
- end;
-
- var
-
- LineApp: LineApplication;
-
- begin
- LineApp.Init('LineApp');
- LineApp.Run;
- LineApp.Done
- end.
-
-
- {--------------------------------------------------------------
- Copyright (c) 1991 by Tom Swan. All rights reserved.
- Revision 1.00 Date: 2/20/1991
- ---------------------------------------------------------------}
-
-